package com.yswl.yeeduo.ui.tool;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

import com.yswl.yeeduo.tool.KStringTool;
/**
 * 应该作为单利
 * @author Administrator
 * 
 */
public class AppManager {
	
	
	/**
	 * 优先  app 是否第一次进入
	 */
	private static final String APP_STATE = "app_state";
	private static final String FirstInstallSpKey = "FirstInstallSpKey";
	public static boolean isFirstOpenApp(Context context){
		SharedPreferences share = context.getSharedPreferences(APP_STATE, Context.MODE_PRIVATE);
		Boolean result = share.getBoolean(FirstInstallSpKey, true);
		if (result) {
			SharedPreferences.Editor editor = share.edit();
			editor.putBoolean(FirstInstallSpKey, false);
			editor.commit();
		}
		return result;
	}
	
	/**
	 * app第一次进入  app进入状态
	 * 任意值
	 * @param context
	 */
	public void setAppStats(Context context, String first) {
		SharedPreferences sp = context.getSharedPreferences(APP_STATE,Activity.MODE_PRIVATE);
		Editor edit = sp.edit();
		edit.putString(FirstInstallSpKey, first);
		edit.commit();
	}

	/**
	 * app是否第一次进入
	 * @param context
	 * @return
	 */
	public boolean isFirst(Context context) {
		SharedPreferences sp = context.getSharedPreferences(APP_STATE,Activity.MODE_PRIVATE);
		String isfirst = sp.getString(FirstInstallSpKey, "");
		return KStringTool.isEmpty(isfirst);
	}
}
